<template>
	<view class="p-x-46 p-t-46">
		<view v-if="!userInfo.mobile" class="left-0 top-0" style="position: fixed; width: 100%; height: 100%; z-index: 9999; top: 200rpx" @click="login.open()"></view>
		<uv-navbar title="AI" placeholder fixed autoBack></uv-navbar>
		<view class="m-x-10 m-b-48">
			<uv-swiper
				:list="bannerList"
				keyName="image"
				@click="
					(e) => {
						swiperClick(bannerList[e]);
					}
				"
				indicator
				height="1165rpx"
				radius="12rpx"
			></uv-swiper>
		</view>
		<!-- <dy-button width="660rpx" shadow @click="getAlreadyCapped"> -->
		<!--  <u-icon :name="ASSETSURL + 'iconAi.png'" space="10rpx" :customStyle="{ 'font-weight': '700', color: '#fff' }"
        size="50rpx" label="开始" label-size="36rpx"></u-icon> -->
		<!-- </dy-button> -->
	</view>
	<view class="p-x-30" @click="getAlreadyCapped">
		<uv-image :src="ASSETSURL + 'aiBtn2.png'" width="690rpx" height="144rpx"></uv-image>
	</view>
	<alreadyCapped ref="alreadyCappeds"></alreadyCapped>
	<dy-login ref="login"></dy-login>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import { ShopCenterApi } from '../../api/serves';
import { useCounter } from '@/mixins/userHooks';
import {
  diyDeductingPoints
} from "@/api/api.js"
const { getUserInfo, userInfo, tool } = useCounter();
const bannerList = ref([]);
const alreadyCappeds = ref(null);
const login = ref(null);

onMounted(() => {
	getbanner();
});

// 获取banner信息
const getbanner = async () => {
	let { code, data, msg } = await ShopCenterApi.getBanner2({ number: 2 });
	if (code != 1) return tool.alert(msg);
	bannerList.value = data;
};
const getAlreadyCapped = () => {
	if (userInfo.value.my_diy < 10) {
		//扣除积分  接口
		diyDeductingPoints().then(res =>{
			  console.log(res,'-----扣除积分----');
		})
		tool.jump_nav('/packageDiy/ai/ai');
	} else {
		alreadyCappeds.value.open();
	}
};
</script>

<style lang="scss" scoped></style>
